#include "uart_proxy.h"

#define APP_version "v1.1.0"

const char* ota_hal_version(unsigned char dev_type, char* dn)
{
    if (dev_type > 0) {
        return "v1.0.0-20180101-1000";//SYSINFO_APP_VERSION;
    }
    else {
        return APP_version;
    }
}

// *********************************************************
static void mqtt_receive_cb(uint8_t* data, uint16_t len)
{
    LOGI("mqtt_receive_cb, %d", len);
}
static void ota_update_complete_cb(void)
{
    LOGI("Firmware update complete, now reboot");
    aos_msleep(100);
    aos_reboot();
}

static uart_proxy_cb_ops_t ops = {
    .mqtt_receive_callback = mqtt_receive_cb,
    .ota_update_complete_callback = ota_update_complete_cb
};
// *********************************************************

// 替换之前 mqtt 发布函数
bool mqtt_publish(const char* json, size_t size)
{
    return uart_proxy_mqtt_publish(json, size);
}

int main()
{
    uart_proxy_init(6, 115200, &ops);

    while(1) {
        mqtt_publish("12345679", 10);
        aos_msleep(1000);
    }
}